package com.sandwich.api.controller.v1;

import com.sandwich.admin.service.ContentDetailService;
import com.sandwich.api.apibean.v1.ContentDetailRequest;
import com.sandwich.api.apibean.v1.ContentSummaryDetail;
import com.sandwich.common.SimpleResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @description 详情信息
 * @date 2021-07-28
 */
@RestController("ApiContentDetailControllerV1")
@RequestMapping("/api/v1")
public class ContentDetailController {
    @Autowired
    private ContentDetailService contentDetailService;

    @PostMapping("/query/contentDetail")
    public ResponseEntity<?> getContentDetail(HttpServletRequest request, @RequestHeader HttpHeaders headers,
                                              @RequestBody ContentDetailRequest contentDetailRequest) {
        ContentSummaryDetail detail = contentDetailService.getContentDetail(contentDetailRequest);
        return new ResponseEntity<>(new SimpleResponse(Stream.of(detail).collect(Collectors.toList())), HttpStatus.OK);
    }

}